from flask import Flask, request
from flask import Blueprint

from sequent import sequent_model_01 as sequent_01
from sequent import sequent_model_02 as sequent_02

sequent_routes = Blueprint('sequent_routes', __name__)


@sequent_routes.route('/sequent_01/v1', methods=['post'])
def sequent_model_01():
    """时间训练模型V1"""
    if not request.data:  # 检测是否有数据
        return ''

    params = request.data.decode('utf-8', errors='ignore')

    prob = sequent_01.process_model(params)

    return str(prob)


@sequent_routes.route('/sequent_02/v1', methods=['post'])
def sequent_model_02():
    """时间训练模型V2"""
    if not request.data:  # 检测是否有数据
        return ''

    params = request.data.decode('utf-8', errors='ignore')

    prob = sequent_02.process_model(params)

    return str(prob)